/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Strategy;


import Adaptor.A_Changle;
import InterfaceClient.IChat;
import Packets.pkValue;
import StaticClass.ArrSocket;
import ThreadClient.ThreadMain;
import java.net.Socket;
import javax.swing.JFrame;

/**
 *
 * @author Oho
 */
public class SI_Chat implements SIPack{

    public void check(pkValue vl,Socket sk) {
        
       if (vl.getCommand() == 1 && ArrSocket.StateChat == false) {

                       IChat  ic1 = new InterfaceClient.IChat(sk, new ThreadMain(sk));
                        ic1.pack();
                        ic1.setVisible(true);
                        ArrSocket.StateChat = true;
                        
                        ArrSocket.ic = ic1;
                    }
                    if (vl.getObj().equals("QUIT")) {
                        ArrSocket.ic.Quit();

                    } else {
                         ConvertPackage(vl,ArrSocket.ic,"Server");
                    }
                    //ConvertPackage(vl, ArrSocket.ic.txtInput, null);
    }

    public void ConvertPackage(pkValue pk, JFrame vic, String str) {
                System.out.println("Client :  " + pk.getObj());
                ArrSocket.  ic.txtInput.append("Client : " +pk.getObj()+"\n");
         
    }
    
}
